import axios from 'axios';
// 请求超时时间
axios.defaults.timeout = 10000;
// post请求头
axios.defaults.headers.Terminalsource = 'pc';
axios.defaults.headers.token = localStorage.getItem("token");
axios.defaults.headers.CurrentOrgID = 0;
axios.defaults.headers.CurrentDepartmentID = 0;
axios.defaults.headers.CurrentLearningStageID = 1;
// 请求数据
/** 
 * get方法，对应get请求 
 * @param {String} url [请求的url地址] 
 * @param {Object} params [请求时携带的参数] 
 */
let _url = 'http://59.110.24.201:8093/vmerpservice';
export function get(url, params) {
	return new Promise((resolve, reject) => {
		let __url = _url + url;
		axios.get(__url, {
				params: params
			})
			.then(res => {
				resolve(res.data);
			})
			.catch(err => {
				reject(err.data)
			})
	});
}
/** 
 * post方法，对应post请求 
 * @param {String} url [请求的url地址] 
 * @param {Object} params [请求时携带的参数] 
 */
export function post(url, params) {
	return new Promise((resolve, reject) => {
		let __url = _url + url;
		axios.post(__url, params)
			.then(res => {
				resolve(res.data);
			})
			.catch(err => {
				reject(err.data)
			})
	});
}
